package chixing.day08.homework;

public abstract class BankAccount {
    //账户号（accountNumber）、账户余额（balance）
    private String accountNumber;
    private double balance;
    //static 成员变量记录总账户数
    private static int allCountNumber;
    public BankAccount(){
        allCountNumber++;
    }
    public BankAccount(String accountNumber, double balance) {
        this();
        this.accountNumber = accountNumber;
        this.balance = balance;
    }

    //抽象方法 void monthlyUpdate()（每月更新利息或扣手续费）
    public abstract void monthlyUpdate();

    //方法 deposit(double amount)存款 和 withdraw(double amount)取款
    public void deposit(double amount){
        balance = balance + amount;
    }
    public void withdraw(double amount){
        balance = balance - amount;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public double getBalance() {
        return balance;
    }

    public static int getAllCountNumber() {
        return allCountNumber;
    }

    public static void setAllCountNumber(int allCountNumber) {
        BankAccount.allCountNumber = allCountNumber;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    @Override
    public String toString() {
        return "BankAccount{" +
                "accountNumber='" + accountNumber + '\'' +
                ", balance=" + balance +
                '}';
    }
}
